package com.jianguozh.difs.framework.utils;

import com.baomidou.mybatisplus.core.toolkit.LambdaUtils;
import com.baomidou.mybatisplus.core.toolkit.support.ColumnCache;

import java.util.Map;

/**
 * mybatis plus 拓展工具类
 * @author hanrs
 * @email 40736130@qq.com
 * @since 2022/4/23 12:58 PM
 */
public class MybatisPlusUtils {

    /**
     * 获取表字段名
     *
     * @param clazz
     * @param propotyName
     * @return
     */
    public static String getColumnName(Class<?> clazz, String propotyName){
        Map<String, ColumnCache> map =  LambdaUtils.getColumnMap(clazz);
        ColumnCache columnCache = map.get(propotyName.toUpperCase());
        return null != columnCache ? columnCache.getColumn() : "";
    }
}
